<?php

session_start();

/**
 * @author Sabine Müller
 * @copyright 2012
 */


include 'nav.inc.php';
include 'dbConn.php';

html_head('Administration - Benutzer l&ouml;schen');

if(!isset($_SESSION["username"])){
	echo("<div class='content' style='margin-left:350px'>");
	   echo ("Bitte erst <a href='login.php'>einloggen</a>.");
	   exit;
	echo("</div");
}
else{
	menu();
	echo("<div class='content' style='margin-left:350px'>");
		if (isset($_REQUEST['next_page']))
			$next_page = $_REQUEST['next_page'];
		else
			$next_page = '0';
		echo ("<form name='main' action='".$_SERVER['SCRIPT_NAME']."' method='post'>\n");
		if($next_page == '0'){
		$db_user_result = mysql_query("SELECT * FROM Login ORDER BY username");
		echo("<tr>");
			echo("<td>");
			echo("<select name='user_id'>");
				echo("<option value=''>User w&auml;hlen:</option>");
				while($user = mysql_fetch_assoc($db_user_result)){
				echo("<option value='".$user['id']."'>".$user['username']."</option>");
				}
			echo("</select>");
			echo("</td>");
		echo("</tr>");
		echo("<tr>");
			 echo ("<td align='center'>");
				 echo"<input type='submit' id='submit' value='L&ouml;schen' />\n";
				 echo"<input type='hidden' name='next_page' value='1' />\n";
			 echo ("</td>");
		echo("</tr>\n");
		mysql_free_result($db_user_result);
		}
		if($next_page == '1'){
			if(isset($_REQUEST['user_id'])){
			$dbHandling->deleteUser($_REQUEST['user_id']);
			echo"<input type='submit' name='button' value='Weiteren User l&ouml;schen' />\n";
			echo"<input type='hidden' name='next_page' value='0' />\n";
			}
		}
		echo("</form>");
	echo("</div>");
}
?>
